
<?php
/**
* 
*/

class Denglu extends GetLoad
{
	
	function __construct()
	{	$this->load("system/SQLcaozuo");
		if(isset($_POST["name"])){
			$this->renzheng();

		}	
		
	}



	public function renzheng(){

		$rusule=$this->SQLquery("SELECT * FROM name where name='".$_POST["name"]."' AND password='".$_POST["password"]."'");

		if($rusule){

			setcookie('name',$rusule[0]['name'],time()+36000);
			setcookie('password',$rusule[0]['password'],time()+36000);
			header("Location: ./index.php?route=Controller/shouye/ControllerShouye/index"); 
		}else{
			//echo "密码有误";
			header("Location: ./index.php?route=Controller/denglu/ControllerDenglu/denglu&=1"); 
		}


	}


	public function huanyingyuxiugai($name_id){
		//var_dump($name_id);
		$rusule=$this->SQLquery("SELECT * FROM name where name='".$_COOKIE["name"]."' AND password='".$_COOKIE["password"]."'");
		if($rusule){
			if($_POST['xuanyan'])
				$this->SQLcun("UPDATE name SET xuanyan = '".$this->escape($_POST['xuanyan'])."' WHERE name = '".$rusule[0]['name']."' ");  
			if($_POST['huanyingyu'])
			$this->SQLcun("UPDATE name SET huanyingyu = '".$this->escape($_POST['huanyingyu'])."' WHERE name = '".$rusule[0]['name']."' ");
			header("Location: ./index.php?route=Controller/zhuye/ControllerZhuye/index&=".$name_id[0]); 

		}else{

			header("Location: ./index.php?route=Controller/denglu/ControllerDenglu/denglu"); 

		}


	}
	public function information($information_id){
		$rusule=$this->SQLquery("SELECT * FROM name where name='".$_COOKIE["name"]."' AND password='".$_COOKIE["password"]."'");
 //var_dump($rusule);
	//echo $information_id[0];
		if($rusule){
			if($_POST['neirong']){
				$this->SQLcun("UPDATE information SET neirong = '".$this->escape($_POST['neirong'])."' WHERE name_id = '".$rusule[0]['name_id']."' AND information_id='".$information_id[0]."' ");
				//echo "UPDATE information SET neirong = '".$this->escape($_POST['neirong'])."' WHERE name_id = '".$rusule[0]['name_id']."' AND information_id='".$information_id[0]."' ";  
			}
			if($_POST['title']){
				$this->SQLcun("UPDATE information SET title = '".$this->escape($_POST['title'])."' WHERE name_id = '".$rusule[0]['name_id']."' AND information_id='".$information_id[0]."' ");  
			}
			$this->SQLcun("UPDATE information SET nian = '".date("Y")."' , yue = '".date("m")."' , ri = '".date("d")."' WHERE name_id = '".$rusule[0]['name_id']."' AND information_id='".$information_id[0]."' "); 
			
			 
		}else{

			header("Location: ./index.php?route=Controller/denglu/ControllerDenglu/denglu"); 

		}

		header("Location: ./index.php?route=Controller/zhuye/ControllerZhuye/index&=".$rusule[0]['name_id']); 


	}

	public function informationtianjia(){

		$rusule=$this->SQLquery("SELECT * FROM name where name='".$_COOKIE["name"]."' AND password='".$_COOKIE["password"]."'");

		if($rusule){
			if($_POST['neirong']){
				$this->SQLcun("INSERT INTO information (name_id,title,neirong,nian,yue,ri) VALUES ('".$rusule[0]['name_id']."','".$this->escape($_POST['title'])."','".$_POST['neirong']."','".date("Y")."','".date("m")."','".date('d')."')");  
				//echo "INSERT INTO information (name_id,title,neirong,nian,yue,ri) VALUES ('".$rusule[0]['name_id']."','".$this->escape($_POST['title'])."','".$_POST['neirong']."','".date("Y")."','".date("m")."','".date('d')."')";
			}


		}else{

			header("Location: ./index.php?route=Controller/denglu/ControllerDenglu/denglu"); 

		}

	header("Location: ./index.php?route=Controller/zhuye/ControllerZhuye/index&=".$rusule[0]['name_id']); 


	}


	public function escape($str) {
 		 	//$str = mysql_real_escape_string($str);
  			$str = str_replace(['_', '%'], ['\\_', '\\%'], $str);
  		return $str;
	}

	public function sixin($data){
		$rusule=$this->SQLquery("SELECT * FROM name where name='".$_COOKIE["name"]."' AND password='".$_COOKIE["password"]."'");

		if($rusule){
			if($_POST['neirong']){
				$this->SQLcun("INSERT INTO sixin (name_id,name2_id,chakan,neirong) VALUES ('".$rusule[0]['name_id']."','".$data[0]."','1','".$_POST['neirong']."')");  
				//echo "INSERT INTO information (name_id,title,neirong,nian,yue,ri) VALUES ('".$rusule[0]['name_id']."','".$this->escape($_POST['title'])."','".$_POST['neirong']."','".date("Y")."','".date("m")."','".date('d')."')";
			}


		}else{

			header("Location: /index.php?route=Controller/denglu/ControllerDenglu/denglu"); 

		}

		header("Location: ./index.php?route=Controller/sixin/ControllerSixin/getsixin&=".$rusule[0]['name_id']); 


	}


}